package com.itheima.api;

/**
 * @author Anomaly
 * @date 2023/2/10 15:14
 */
public class ThreadDemo {
    public static void main(String[] args) {
        Thread t1 = new MyThread("线程1");
        Thread t2 = new MyThread("线程2");
        t1.start();
        t2.start();

        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread() + "主线程输出" + i);
        }
    }
}

class MyThread extends Thread {
    public MyThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(currentThread() + "输出" + i);
        }
    }
}